package pl.polsl.pum2.pj.rubik;

import android.graphics.Color;

/**
 * Simple holder of color and ID. <br/>
 * Every external cube has a max of six colored sides and a unique id.<br/>
 * Similarly the background has its color (black) and its id = 255. <br/>
 * <br/>
 * The ID is actually the alpha channel value read from backbuffer pixels.
 */
public class ColorAndId {
  private int              color;
  private int              id;

  public static ColorAndId zero = new ColorAndId(0, 0, 0, 255);

  public ColorAndId() {}

  public ColorAndId(int r, int g, int b, int a) {
    id = a;
    color = Color.rgb(r, g, b);
  }

  public void setColor(int r, int g, int b) {
    color = Color.rgb(r, g, b);
  }

  public int getColor() {
    return color;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getId() {
    return id;
  }

  public boolean equals(Object o) {
    if (o instanceof ColorAndId) {
      ColorAndId that = (ColorAndId) o;
      return this.color == that.color && this.id == that.id;
    }
    return false;
  }

  public String toString() {
    return "ColorAndId[color=" + color + ";id=" + id + "];";
  }

  public static final int WHITE  = Color.rgb(255, 255, 255);
  public static final int YELLOW = Color.rgb(255, 255, 0);
  public static final int RED    = Color.rgb(255, 0, 0);
  public static final int ORANGE = Color.rgb(255, 128, 0);
  public static final int GREEN  = Color.rgb(0, 255, 0);
  public static final int BLUE   = Color.rgb(0, 0, 255);
}
